package com.browsesoft.user;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import com.browsesoft.EntityManager;
import com.browsesoft.baseadapter.SimpleEntity;

/**
 * <p>Title: 用户工具类</p>
 * <p>Description: 得到用户的有关信息</p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */
public class UserHelper
{
  /**
   * 得到用户的审批常用语
   */
  public static List getOffenWords(User user) {
    try
    {
      List result = new LinkedList();
      String ename = user.getEName();
      List words = EntityManager.getInstance().getEntities("offenwords", "f_ename", ename);
      Iterator iter = words.iterator();
      while (iter.hasNext())
      {
        SimpleEntity item = (SimpleEntity) iter.next();
        result.add(item.getAttributes().get("f_offenwords"));
      }
      return result;
    }
    catch (Exception ex)
    {
      throw new RuntimeException(ex);
    }
  }

  /**
   * 得到用户的签字图片名
   */
  public static String getSign(User user) {
    try
    {
      String ename = user.getEName();
      SimpleEntity entity = (SimpleEntity)EntityManager.getInstance().getEntities("leadersign", "f_ename", ename).get(0);
      return (String)entity.getAttributes().get("f_leadersign");
    }
    catch (Exception ex)
    {
      throw new RuntimeException(ex);
    }
  }

  }
